﻿Public Class BlockSixHomeworkSectionSix
    Dim QuestionNumber As Integer
    Dim dtmTest, dtmTest2 As Date
    Dim filename As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    'Declare the Array as 10 rows and 3 columns
    Dim ArrayMax As Integer = 54 'One number past the end of actual info in array
    Dim HWQuestions(ArrayMax, 3) As String
    Dim intResponse As Integer
    Dim intQuestionCount As Integer = 0
    Dim intAnswerCount As Integer = 0
    Dim intReferenceCount As Integer = 0
    Dim intFirstRun As Integer = 1
    Dim strUser As String = "Enter Last Name"
    Dim strAnswer, strAnswer2, strAnswer3, strAnswer4, strAnswer5, _
     strAnswer6, strAnswer7, strAnswer8, strAnswer9, strAnswer10, strAnswer11, _
     strAnswer12, strAnswer13, strAnswer14, strAnswer15, strAnswer16, _
     strAnswer17, strAnswer18, strAnswer19, strAnswer20, strAnswer21, _
     strAnswer22, strAnswer23, strAnswer24, strAnswer25, strAnswer26, _
     strAnswer27, strAnswer28, strAnswer29, strAnswer30, strAnswer31, _
     strAnswer32, strAnswer33, strAnswer34, strAnswer35, strAnswer36, _
     strAnswer37, strAnswer38, strAnswer39, strAnswer40, strAnswer41, _
     strAnswer42, strAnswer43, strAnswer44, strAnswer45, strAnswer46, _
     strAnswer47, strAnswer48, strAnswer49, strAnswer50, strAnswer51, _
     strAnswer52, strAnswer53 As String
    Dim intChoiceACount As Integer = 2
    Dim intChoiceBCount As Integer = 3
    Dim intChoiceCCount As Integer = 4
    Dim intChoiceDCount As Integer = 5

    Shared Property MidiParent As MainForm

    Private Sub CloseToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles CloseToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub BlockTwoHomeworkSectionOne_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        txtObj.Text = "Objectives:" + vbCrLf + "- Given proper student instructional materials, identify the operating principles of the Localizer Course Transmitter." _
            + vbCrLf + " - Given proper student instructional materials, identify the operating principles of the Localizer Clearance Transmitter." _
            + vbCrLf + " - Given proper student instructional materials, identify the operating principles of the Localizer Antenna Array."
        If (System.IO.File.Exists(filename & "\Homework\Block 6\Block 6 Section 6.txt")) Then
            intResponse = MsgBox("This assignment has already been completed.  Are you sure you want to delete the current assignment and reaccomplish it?", 4, "Confirm Assignment Deletion")
            If intResponse = MsgBoxResult.Yes Then
                System.IO.File.Delete(filename & "\Homework\Block 6\Block 6 Section 6.txt")
                System.IO.File.Create(filename & "\Homework\Block 6\Block 6 Section 6.txt").Dispose()
            ElseIf intResponse = MsgBoxResult.No Then
                Me.Close()
            End If
        End If
        If (Not System.IO.File.Exists(filename & "\Homework\Block 6\Block 6 Section 6.txt")) Then
            System.IO.File.Create(filename & "\Homework\Block 6\Block 6 Section 6.txt").Dispose()
        End If
        If (Not System.IO.File.Exists(filename & "\Instructor\Block 6\Block 6 Section 6.txt")) Then
            System.IO.File.Create(filename & "\Instructor\Block 6\Block 6 Section 6.txt").Dispose()
        End If
        strUser = InputBox("Please enter last name", strUser)
        If strUser Is "" Then
            Me.Close()
        End If
        '************************************************
        '****** Questions Are Loaded Here****************
        '******* Column 1 is Questions (Preloaded)*******
        '******* Column 2 is Accepts Students Answer*****
        '******* Column 3 is Reference ******************

        'Transmitter Functional Block Diagram
        HWQuestions(1, 1) = ""
        HWQuestions(1, 2) = ""
        HWQuestions(1, 3) = ""

        HWQuestions(2, 1) = ""
        HWQuestions(2, 2) = ""
        HWQuestions(2, 3) = ""

        HWQuestions(3, 1) = ""
        HWQuestions(3, 2) = ""
        HWQuestions(3, 3) = ""

        HWQuestions(4, 1) = ""
        HWQuestions(4, 2) = ""
        HWQuestions(4, 3) = ""

        HWQuestions(5, 1) = ""
        HWQuestions(5, 2) = ""
        HWQuestions(5, 3) = ""

        '4A1/15A1 Synthesized Frequency Source
        HWQuestions(6, 1) = ""
        HWQuestions(6, 2) = ""
        HWQuestions(6, 3) = ""

        HWQuestions(7, 1) = ""
        HWQuestions(7, 2) = ""
        HWQuestions(7, 3) = ""

        HWQuestions(8, 1) = ""
        HWQuestions(8, 2) = ""
        HWQuestions(8, 3) = ""

        HWQuestions(9, 1) = ""
        HWQuestions(9, 2) = ""
        HWQuestions(9, 3) = ""

        '4A9/15A1 Diode Switching Network
        HWQuestions(10, 1) = ""
        HWQuestions(10, 2) = ""
        HWQuestions(10, 3) = ""

        '4A10 90/150 Hz Generator
        HWQuestions(11, 1) = ""
        HWQuestions(11, 2) = ""
        HWQuestions(11, 3) = ""

        HWQuestions(12, 1) = ""
        HWQuestions(12, 2) = ""
        HWQuestions(12, 3) = ""

        HWQuestions(13, 1) = ""
        HWQuestions(13, 2) = ""
        HWQuestions(13, 3) = ""

        HWQuestions(14, 1) = ""
        HWQuestions(14, 2) = ""
        HWQuestions(14, 3) = ""

        HWQuestions(15, 1) = ""
        HWQuestions(15, 2) = ""
        HWQuestions(15, 3) = ""

        HWQuestions(16, 1) = ""
        HWQuestions(16, 2) = ""
        HWQuestions(16, 3) = ""

        HWQuestions(17, 1) = ""
        HWQuestions(17, 2) = ""
        HWQuestions(17, 3) = ""

        '4A2/A3 ID Circuits
        HWQuestions(18, 1) = ""
        HWQuestions(18, 2) = ""
        HWQuestions(18, 3) = ""

        HWQuestions(19, 1) = ""
        HWQuestions(19, 2) = ""
        HWQuestions(19, 3) = ""

        '4A8/15A8 Modulator
        HWQuestions(20, 1) = ""
        HWQuestions(20, 2) = ""
        HWQuestions(20, 3) = ""

        HWQuestions(21, 1) = ""
        HWQuestions(21, 2) = ""
        HWQuestions(21, 3) = ""

        HWQuestions(22, 1) = ""
        HWQuestions(22, 2) = ""
        HWQuestions(22, 3) = ""

        HWQuestions(23, 1) = ""
        HWQuestions(23, 2) = ""
        HWQuestions(23, 3) = ""

        HWQuestions(24, 1) = ""
        HWQuestions(24, 2) = ""
        HWQuestions(24, 3) = ""

        HWQuestions(25, 1) = ""
        HWQuestions(25, 2) = ""
        HWQuestions(25, 3) = ""

        HWQuestions(26, 1) = ""
        HWQuestions(26, 2) = ""
        HWQuestions(26, 3) = ""

        HWQuestions(27, 1) = ""
        HWQuestions(27, 2) = ""
        HWQuestions(27, 3) = ""

        HWQuestions(28, 1) = ""
        HWQuestions(28, 2) = ""
        HWQuestions(28, 3) = ""

        '4A4,4A5/15A4, 15A5 RF Amplifiers
        HWQuestions(29, 1) = ""
        HWQuestions(29, 2) = ""
        HWQuestions(29, 3) = ""

        HWQuestions(30, 1) = ""
        HWQuestions(30, 2) = ""
        HWQuestions(30, 3) = ""

        HWQuestions(31, 1) = ""
        HWQuestions(31, 2) = ""
        HWQuestions(31, 3) = ""

        '4A6, 4A7/15A6, 15A7 Filter/Detector
        HWQuestions(32, 1) = ""
        HWQuestions(32, 2) = ""
        HWQuestions(32, 3) = ""

        '15A10 90/150 Hz Control Assembly
        HWQuestions(33, 1) = ""
        HWQuestions(33, 2) = ""
        HWQuestions(33, 3) = ""

        HWQuestions(34, 1) = ""
        HWQuestions(34, 2) = ""
        HWQuestions(34, 3) = ""

        '4AT1/15AT1 Sideband Amplitude Control
        HWQuestions(35, 1) = ""
        HWQuestions(35, 2) = ""
        HWQuestions(35, 3) = ""

        '4Z1/15Z1 Sideband Phaser
        HWQuestions(36, 1) = ""
        HWQuestions(36, 2) = ""
        HWQuestions(36, 3) = ""

        'Changeover Unit (Unit 8)
        HWQuestions(37, 1) = ""
        HWQuestions(37, 2) = ""
        HWQuestions(37, 3) = ""

        HWQuestions(38, 1) = ""
        HWQuestions(38, 2) = ""
        HWQuestions(38, 3) = ""

        HWQuestions(39, 1) = ""
        HWQuestions(39, 2) = ""
        HWQuestions(39, 3) = ""

        'Interlock Control Assembly (1A4)
        HWQuestions(40, 1) = ""
        HWQuestions(40, 2) = ""
        HWQuestions(40, 3) = ""

        HWQuestions(41, 1) = ""
        HWQuestions(41, 2) = ""
        HWQuestions(41, 3) = ""

        'Antenna Distribution Unit (Unit 6)
        HWQuestions(42, 1) = ""
        HWQuestions(42, 2) = ""
        HWQuestions(42, 3) = ""

        HWQuestions(43, 1) = ""
        HWQuestions(43, 2) = ""
        HWQuestions(43, 3) = ""

        HWQuestions(44, 1) = ""
        HWQuestions(44, 2) = ""
        HWQuestions(44, 3) = ""

        HWQuestions(45, 1) = ""
        HWQuestions(45, 2) = ""
        HWQuestions(45, 3) = ""

        'Radiation(Pattern)
        HWQuestions(46, 1) = ""
        HWQuestions(46, 2) = ""
        HWQuestions(46, 3) = ""

        HWQuestions(47, 1) = ""
        HWQuestions(47, 2) = ""
        HWQuestions(47, 3) = ""

        HWQuestions(48, 1) = ""
        HWQuestions(48, 2) = ""
        HWQuestions(48, 3) = ""

        HWQuestions(49, 1) = ""
        HWQuestions(49, 2) = ""
        HWQuestions(49, 3) = ""

        HWQuestions(50, 1) = ""
        HWQuestions(50, 2) = ""
        HWQuestions(50, 3) = ""

        HWQuestions(51, 1) = ""
        HWQuestions(51, 2) = ""
        HWQuestions(51, 3) = ""

        HWQuestions(52, 1) = ""
        HWQuestions(52, 2) = ""
        HWQuestions(52, 3) = ""

        HWQuestions(53, 1) = ""
        HWQuestions(53, 2) = ""
        HWQuestions(53, 3) = ""

        HWQuestions(54, 1) = ""

        Next_Question(HWQuestions)
    End Sub

    Private Sub btnNextQuestion_Click(sender As System.Object, e As System.EventArgs) Handles btnNextQuestion.Click
        Next_Question(HWQuestions)
    End Sub
    Private Sub Clear_Display()
        txtQuestion.Clear()
        txtAnswer.Clear()
    End Sub

    Public Function Next_Question(HWQuestions As String(,))
        txtAnswer.Focus()
        If intQuestionCount > 0 Then
            WriteToFile()
        End If
        If btnNextQuestion.Text = "Done" Then
            Me.Close()
            OpenResults()
        End If
        intQuestionCount = intQuestionCount + 1
        LabelChangeCheck()
        If intQuestionCount = 53 Then
            btnNextQuestion.Text = "Done"
        End If
        txtQuestion.Text = HWQuestions(intQuestionCount, 1)
        intAnswerCount = intAnswerCount + 1
        HWQuestions(intAnswerCount, 2) = txtAnswer.Text
        intReferenceCount = intReferenceCount + 1
        txtReference.Text = HWQuestions(intReferenceCount, 3)

        Return intQuestionCount & intAnswerCount
    End Function

    Private Sub LabelChangeCheck()
        If intQuestionCount = 1 Then
            lblSubject.Text = "Transmitter Functional Block Diagram"
        ElseIf intQuestionCount = 6 Then
            lblSubject.Text = "4A1/15A1 Synthesized Frequency Source"
        ElseIf intQuestionCount = 10 Then
            lblSubject.Text = "4A9/15A1 Diode Switching Network"
        ElseIf intQuestionCount = 11 Then
            lblSubject.Text = "4A10 90/150 Hz Generator"
        ElseIf intQuestionCount = 18 Then
            lblSubject.Text = "4A2/A3 ID Circuits"
        ElseIf intQuestionCount = 20 Then
            lblSubject.Text = "4A8/15A8 Modulator"
        ElseIf intQuestionCount = 29 Then
            lblSubject.Text = "4A4,4A5/15A4, 15A5 RF Amplifiers"
        ElseIf intQuestionCount = 32 Then
            lblSubject.Text = "4A6, 4A7/15A6, 15A7 Filter/Detector"
        ElseIf intQuestionCount = 33 Then
            lblSubject.Text = "15A10 90/150 Hz Control Assembly"
        ElseIf intQuestionCount = 35 Then
            lblSubject.Text = "4AT1/15AT1 Sideband Amplitude Control"
        ElseIf intQuestionCount = 36 Then
            lblSubject.Text = "4Z1/15Z1 Sideband Phaser"
        ElseIf intQuestionCount = 37 Then
            lblSubject.Text = "Changeover Unit (Unit 8)"
        ElseIf intQuestionCount = 40 Then
            lblSubject.Text = "Interlock Control Assembly (1A4)"
        ElseIf intQuestionCount = 42 Then
            lblSubject.Text = "Antenna Distribution Unit (Unit 6)"
        ElseIf intQuestionCount = 46 Then
            lblSubject.Text = "Radiation(Pattern)"
        End If
    End Sub

    Private Sub WriteToFile()
        Dim Integrity As String = (filename & "\Instructor\Block 6\Block 6 Section 6.txt")
        Dim Results As String = (filename & "\Homework\Block 6\Block 6 Section 6.txt")

        '***********Output to hidden file for Instructor Check***********
        If System.IO.File.Exists(Integrity) = True Then
            Dim hiddenWriter As New System.IO.StreamWriter(Integrity, True)
            If intQuestionCount = 1 Then
                hiddenWriter.WriteLine("- " & txtObj.Text)
                hiddenWriter.WriteLine()
                hiddenWriter.WriteLine("Student: " & strUser)
                hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
            hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
            hiddenWriter.WriteLine("Reference: " & txtReference.Text)
            hiddenWriter.WriteLine()
            If intQuestionCount = 53 Then
                hiddenWriter.WriteLine("Block 6 Section 6 Homework Complete")
                hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.Close()

            'MsgBox("Text written to file")
        Else
            MsgBox("File Does Not Exist Integrity")
        End If

        '******Output to file for Student to review***********
        If System.IO.File.Exists(Results) = True Then
            Dim hiddenWriter As New System.IO.StreamWriter(Results, True)
            If intQuestionCount = 1 Then
                hiddenWriter.WriteLine("- " & txtObj.Text)
                hiddenWriter.WriteLine()
                hiddenWriter.WriteLine("Student: " & strUser)
                'hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                'hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
            hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
            'hiddenWriter.WriteLine("Reference: " & txtReference.Text)
            hiddenWriter.WriteLine()
            If intQuestionCount = 53 Then
                hiddenWriter.WriteLine("Block 6 Section 6 Homework Complete")
                'hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                'hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.Close()

            'MsgBox("Text written to file")
        Else
            MsgBox("File Does Not Exist Results")
        End If

        If intQuestionCount > 0 Then
            txtAnswer.Clear()
        End If

    End Sub

    Private Sub OpenResults()
        Dim p As Process = Process.Start(filename & "\Homework\Block 6\Block 6 Section 6.txt")
    End Sub
End Class
